<template>
    <div class="embed-responsive embed-responsive-16by9">
        <video :src=streamURL autoplay class="embed-responsive-item"></video>
    </div>
</template>

<script>
/* eslint-disable */
import { getNavigatorMedia } from '../static/utils'
import { mq } from './mq'
import { mapMutations } from 'vuex'

export default {
    name: 'camera',
    data () {
        return {
            streamURL:null
        }
    },
    methods: {
        ...mapMutations(['localVideoStreamRef'])
    },
    created(){
        //var constraints = { audio: true, video: { width: 1280, height: 720 } };
        var vm = this;
        getNavigatorMedia({video: true,audio: true})
        .then(function(stream) {
            vm.streamURL = window.URL.createObjectURL(stream);
            vm.localVideoStreamRef(stream);
        })
        .catch(function(err) {
            console.log(err.name + ": " + err.message);
        });
    }
}
</script>